home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 51 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.7 KB  |  49 lines

  1. Path: chronicle.mti.sgi.com!austern
  2. From: clamage@Eng.Sun.COM (Steve Clamage)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Defining object in function call
  5. Date: 16 Jan 1996 10:05:23 PST
  6. Organization: Sun Microsystems Inc., Mountain View, CA
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4df1eo$7oj@engnews1.Eng.Sun.COM>
  9. References: <4de4lg$mfu@darkstar.UCSC.EDU>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: 16 Jan 1996 02:10:32 GMT
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMPvo9ky4NqrwXLNJAQHmbQH/X/Q1RotWJBRNk/lifFGgmgc9i1qdlANR
  14.     4YLJg/st0gcqeivA+DK0U5sUsgApz3SC2GMQihRr4ty+YA1xiyLY7A==
  15.     =uoDS
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. ray@cse.ucsc.edu (Ray Swartz) writes:
  19.  
  20. >I read somewhere (this newsgroup, I think) that the limitation on
  21. >defining variables/objects in function calls had been lifted.
  22.  
  23. >I tried to find this in the April WP but failed.
  24.  
  25. If you mean something like
  26.  
  27.     void foo(int);
  28.  
  29.     main()
  30.     {
  31.         foo(int i = 12);     // valid?
  32.  
  33. that has never been allowed as a function call. (The example is
  34. a valid construct, but it re-declares 'foo' to have a default
  35. argument of value 12. It is not a function call.)
  36. This example shows one reason why it isn't allowed: ambiguity.
  37.  
  38. A function call contains a list of expressions, and an expression
  39. cannot contain a variable definition. (The "condition" part of a
  40. selection statement or loop may now contain a variable definition,
  41. but those are not expressions.)
  42.  
  43. --
  44. Steve Clamage, stephen.clamage@eng.sun.com
  45. ---
  46. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  47.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  48.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  49.